<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>为同一个元素绑定多个不同事件指向同一个事件处理函数</title>
</head>
<body>
  <input type="button" name="btn" id="btn" value="btnbtnbtn"/>
  <script>
    var btn = document.getElementById('btn');
    function f1(e) {
      // console.log(e);
      switch (e.type) {
        case 'click':
          alert('董喜炜和岳婷婷很幸福哦~！');
          break;
        case 'mouseover':
          this.style.backgroundColor = 'red';
          break;
        case 'mouseout':
          this.style.backgroundColor = 'pink';
          break;
        default:
          break;
      }
    }
    btn.onclick = f1;
    btn.onmouseover = f1;
    btn.onmouseout = f1;
    // document.onkeydown = function (e) {
    //   console.log(e);
    // };
  </script>
</body>
</html>